import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 666
 * Date: 2023-04-13
 * Time: 23:51
 */
public class test2 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int m = scanner.nextInt();
        int n = scanner.nextInt();
        int[] arr = new int[m + n];
        int[] arr1 = new int[n];
        for (int i = 0; i < m; i++) {
            arr[i] = scanner.nextInt();
        }
        for (int i = 0; i < n; i++) {
            arr1[i] = scanner.nextInt();
        }
        while (m > 1) {
            int tmp = 0;
            if (arr[m-1] >= arr1[n-1] && m > 1 && n > 1) {
                arr[m + n-1] = arr[m-1];
                m--;
            } else {
                arr[m + n-1] = arr1[n-1];
                n--;
            }
            if (m < 0) {
                for (int i = 0; i < n; i++) {
                    arr[i] = arr1[n];
                }
            }
        }
    }
}
